Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
remark-toc
Advanced tools
Generate a Table of Contents in remark.
npm:
npm install remark-toc
Say we have the following file, example.md
:
# Alpha
## Table of Contents
## Bravo
### Charlie
## Delta
And our script, example.js
, looks as follows:
var vfile = require('to-vfile')
var remark = require('remark')
var toc = require('remark-toc')
remark()
.use(toc)
.process(vfile.readSync('example.md'), function(err, file) {
if (err) throw err
console.log(String(file))
})
Now, running node example
yields:
# Alpha
## Table of Contents
- [Bravo](#bravo)
- [Charlie](#charlie)
- [Delta](#delta)
## Bravo
### Charlie
## Delta
remark().use(toc[, options])
Add a Table of Contents to a Markdown document.
'Table of Contents'
, 'toc'
,
or 'table-of-contents'
(case insensitive, supports alt/title attributes
for links and images too)heading
string?
, default: 'toc|table[ -]of[ -]contents?'
— Heading to look for,
wrapped in new RegExp('^(' + value + ')$', 'i')
.
maxDepth
number?
, default: 6
— Maximum heading depth to include in the table of
contents, This is inclusive, thus, when set to 3
, level three headings,
are included (those with three hashes, ###
).
tight
boolean?
, default: false
— Whether to compile list-items tightly.
remark-collapse
– Make a section collapsibleremark-normalize-headings
— Make sure there is no more than a single top-level heading in the document
and rewrite the rest accordinglyremark-rewrite-headers
— Change header levelsmdast-util-toc
— Core functionality of this pluginSee contributing.md
in remarkjs/remark
for ways to get
started.
This organisation has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.
FAQs
remark plugin to generate a table of contents (TOC)
We found that remark-toc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.